import 'package:flutter/material.dart';
import 'My.dart';
import 'findMovies.dart';
import 'HotWidget.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '豆瓣电影',
      home: MyHomePage(title: '豆瓣电影'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _tabIndex = 0;
  final _widgetItems = [HotMovies(), FindMovies(), My()];
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: _widgetItems[_tabIndex],
      ),
      bottomNavigationBar: BottomNavigationBar(
        items: [
          BottomNavigationBarItem(icon: Icon(Icons.school), label: '热映'),
          BottomNavigationBarItem(
              icon: Icon(Icons.panorama_fish_eye), label: '找片'),
          BottomNavigationBarItem(icon: Icon(Icons.people), label: '我的'),
        ],
        currentIndex: _tabIndex,
        fixedColor: Colors.black,
        type: BottomNavigationBarType.fixed,
        onTap: _onItemTapped,
      ),
    );
  }

  void _onItemTapped(int index) {
    setState(() {
      _tabIndex = index;
    });
  }
}
